[codex] Skip core SEO routes when site routes exist#1386
Conversation
🦋 Changeset detectedLatest commit: 06f3d4b The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
/review |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
This is a clean, well-scoped bug fix. The approach—checking src/pages for existing root routes and skipping EmDash's default robots.txt/sitemap.xml injection—is sensible and fits the integration's build-time architecture. The change is additive, backwards-compatible, and includes targeted tests with good coverage of the direct-file and index.* subdirectory patterns.
I checked the diff, the routes.ts implementation, the call site in index.ts, and the new unit tests. Logic is correct, the srcDir URL-to-path conversion is done safely with fileURLToPath, and the fallback (!options.srcDir) safely defaults to injecting the routes.
One gap: ROUTE_OVERRIDE_EXTENSIONS omits .md, .mdx, and .html, which Astro also recognizes as valid page file extensions. A user with src/pages/robots.txt.md or src/pages/sitemap.xml.html would still receive duplicate-route warnings because the override check wouldn't find them. Adding those extensions would make the detection fully cover Astro's built-in page types. This is a suggestion rather than a blocker because the realistic overrides are covered.
| } | ||
|
|
||
| const ROUTE_OVERRIDE_EXTENSIONS = [".astro", ".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts"]; | ||
|
|
There was a problem hiding this comment.
[suggestion] ROUTE_OVERRIDE_EXTENSIONS currently misses .md, .mdx, and .html. Astro treats all of these as valid page file extensions in src/pages, so a user with e.g. src/pages/robots.txt.md or src/pages/sitemap.xml.html would still hit duplicate-route warnings that this PR intends to avoid.
| const ROUTE_OVERRIDE_EXTENSIONS = [".astro", ".js", ".ts", ".jsx", ".tsx", ".mjs", ".mts", ".md", ".mdx", ".html"]; |
|
/review |
What does this PR do?
Skips EmDash's default root
robots.txtandsitemap.xmlroute injection when the host Astro site already defines its own matching root route undersrc/pages.This avoids duplicate static route warnings today and prevents future Astro versions from turning those duplicate root routes into hard errors. Per-collection EmDash sitemaps (
/sitemap-[collection].xml) continue to be injected.Closes: N/A
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output
Validation run locally:
Before root
pnpm typecheck, local package artifacts were rebuilt after refreshingnode_modules: